package com.supreme.nettyapp.generalserver.mqttserver.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.mqtt.MqttDecoder;
import io.netty.handler.codec.mqtt.MqttEncoder;

public class MqttServerInitializer extends ChannelInitializer<SocketChannel> {

    public static final MqttServerInitializer INSTANCE = new MqttServerInitializer();

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        pipeline.addLast("encoder", MqttEncoder.INSTANCE);
        pipeline.addLast("decoder", new MqttDecoder());
        pipeline.addLast("handler", new MqttServerHandler());
    }
}
